home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
tvdmx.exe
/
TVDMXBUF.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-07-16
|
22KB
|
846 lines
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
{ }
{ tvDMXBUF --Buffered Data Editing Unit }
{ tvDMX --data editing project (ver 1.4) }
{ }
{ Copyright (c) 1992 Randolph Beck }
{ P.O. Box 56-0487 }
{ Orlando, FL 32856 }
{ CIS: 72361,753 }
{ }
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
Unit tvDMXBUF;
{$B-,D-,R-,O+,X+,V- }
interface
uses
Objects, Drivers, Views, Dialogs, App, MsgBox,
RSet, DmxGizma, tvDMX, StdDMX;
const
EmptySlot = -1;
type
PSlot = ^TSlot;
TSlot = RECORD
Data : pointer;
RowNum : integer;
end;
PRowSlots = ^TRowSlots;
TRowSlots = array [0..99] of TSlot;
PDmxEditBuf = ^TDmxEditBuf;
PDmxStreamBuf = ^TDmxStreamBuf;
PDmxExpBuf = ^TDmxExpBuf;
PDmxExpRecInd = ^TDmxExpRecInd;
PDmxBufWin = ^TDmxBufWin;
PDmxExpBufWin = ^TDmxExpBufWin;
PDmxEditRecBuf = ^TDmxEditRecBuf;
TDmxEditBuf = OBJECT (TDmxEditor)
NumSlots : integer;
RowSlot : PRowSlots;
KeyFields : set of byte;
KeyAltered : boolean;
Expandable : boolean;
Appending : boolean;
StepMode : boolean;
constructor Load (var S : TStream);
procedure Store (var S : TStream);
procedure LoadStruct (var S : TStream); VIRTUAL;
procedure MakeSlots;
procedure ResetSlots;
procedure InitStruct (var ATemplate ); VIRTUAL;
procedure DoneStruct; VIRTUAL;
procedure HandleEvent (var Event : TEvent); VIRTUAL;
procedure SetState (AState : word; Enable : boolean); VIRTUAL;
function DataAt (RecNum : integer) : pointer; VIRTUAL;
procedure SetUpRecord; VIRTUAL;
procedure EvaluateRecord; VIRTUAL;
procedure EvaluateField; VIRTUAL;
procedure ZeroizeField (Whole : boolean; Field : pDMXfieldrec); VIRTUAL;
procedure ResetSize;
function RecordLimit : integer; VIRTUAL;
function ErrorFunc : boolean; VIRTUAL;
function SeekRec (RecNum : integer) : boolean; VIRTUAL;
function SeekEnd : boolean; VIRTUAL;
function ReadRec (var RecData ) : boolean; VIRTUAL;
function WriteRec (var RecData ) : boolean; VIRTUAL;
private
NewRecord : boolean; { indicates this is a new record }
end;
TDmxStreamBuf = OBJECT (TDmxEditBuf)
Prefix : pointer;
PrefixSize : integer;
procedure LoadStruct (var S : TStream); VIRTUAL;
procedure StoreStruct (var S : TStream); VIRTUAL;
function RecordLimit : integer; VIRTUAL;
function ErrorFunc : boolean; VIRTUAL;
function SeekRec (RecNum : integer) : boolean; VIRTUAL;
function SeekEnd : boolean; VIRTUAL;
function ReadRec (var RecData ) : boolean; VIRTUAL;
function WriteRec (var RecData ) : boolean; VIRTUAL;
end;
TDmxExpBuf = OBJECT (TDmxStreamBuf)
procedure InitData (var AData ); VIRTUAL;
end;
TDmxExpRecInd = OBJECT (TDmxRecInd)
procedure Draw; VIRTUAL;
end;
TDmxBufWin = OBJECT (TDmxWindow)
procedure InitDMX (ATemplate : string; var AData;
ALabels, ARecInd : PDmxLink;
BSize : longint); VIRTUAL;
end;
TDmxExpBufWin = OBJECT (TDmxWindow)
procedure InitDMX (ATemplate : string; var AData;
ALabels, ARecInd : PDmxLink;
BSize : longint); VIRTUAL;
function NewRecInd (Len : integer) : PDmxLink; VIRTUAL;
end;
TDmxEditRecBuf = OBJECT (TDmxEditBuf)
RecPosition : longint;
procedure InitData (var AData ); VIRTUAL;
procedure ZeroizeRecord; VIRTUAL;
function SeekRec (RecNum : integer) : boolean; VIRTUAL;
function SeekEnd : boolean; VIRTUAL;
procedure DeleteRec; VIRTUAL;
function WriteRec (var RecData ) : boolean; VIRTUAL;
function AppendRec (var RecData ) : boolean; VIRTUAL;
function UpdateRec (var RecData ) : boolean; VIRTUAL;
function FirstRec : boolean; VIRTUAL;
function LastRec : boolean; VIRTUAL;
function NextRec : boolean; VIRTUAL;
function PrevRec : boolean; VIRTUAL;
end;
const
RDmxStreamBuf : TStreamRec = (
ObjType: cmDMX + 10;
VmtLink: ofs (TypeOf (TDmxStreamBuf)^);
Load: @TDmxStreamBuf.Load;
Store: @TDmxStreamBuf.Store
);
RDmxExpBuf : TStreamRec = (
ObjType: cmDMX + 11;
VmtLink: ofs (TypeOf (TDmxExpBuf)^);
Load: @TDmxExpBuf.Load;
Store: @TDmxExpBuf.Store
);
RDmxExpRecInd : TStreamRec = (
ObjType: cmDMX + 12;
VmtLink: ofs (TypeOf (TDmxExpRecInd)^);
Load: @TDmxExpRecInd.Load;
Store: @TDmxExpRecInd.Store
);
RDmxBufWin : TStreamRec = (
ObjType: cmDMX + 13;
VmtLink: ofs (TypeOf (TDmxBufWin)^);
Load: @TDmxBufWin.Load;
Store: @TDmxBufWin.Store
);
RDmxExpBufWin : TStreamRec = (
ObjType: cmDMX + 14;
VmtLink: ofs (TypeOf (TDmxExpBufWin)^);
Load: @TDmxExpBufWin.Load;
Store: @TDmxExpBufWin.Store
);
implementation
{ ══ TDmxEditBuf ═══════════════════════════════════════════════════════ }
constructor TDmxEditBuf.Load (var S : TStream);
begin
TDmxEditor.Load (S);
S.Read (KeyFields, sizeof (KeyFields));
S.Read (Expandable, sizeof (Expandable));
S.Read (StepMode, sizeof (StepMode));
end;
procedure TDmxEditBuf.Store (var S : TStream);
begin
TDmxEditor.Store (S);
S.Write (KeyFields, sizeof (KeyFields));
S.Write (Expandable, sizeof (Expandable));
S.Write (StepMode, sizeof (StepMode));
end;
procedure TDmxEditBuf.LoadStruct (var S : TStream);
begin
TDmxEditor.LoadStruct (S);
MakeSlots;
end;
procedure TDmxEditBuf.MakeSlots;
var i : integer;
begin
If InitValid and (RecordSize > 0) then
begin
NumSlots := ScreenHeight;
If (HiResScreen and (NumSlots < 30)) then NumSlots := 46;
If (NumSlots < Size.Y) then NumSlots := Size.Y;
GetMem (RowSlot, NumSlots * sizeof (TSlot));
fillchar (RowSlot^, NumSlots * sizeof (TSlot), 0);
For i := 0 to pred (NumSlots) do
begin
If ((MaxAvail shr 4) > RecordSize) then
begin
RowSlot^ [i].RowNum := EmptySlot;
GetMem (RowSlot^ [i].Data, RecordSize);
end
else
InitValid := FALSE;
end;
end;
end;
procedure TDmxEditBuf.ResetSlots;
var i : integer;
begin
If (NumSlots > 0) then
For i := 0 to pred (NumSlots) do RowSlot^ [i].RowNum := EmptySlot;
end;
procedure TDmxEditBuf.InitStruct (var ATemplate );
begin
TDmxEditor.InitStruct (ATemplate);
MakeSlots;
end;
procedure TDmxEditBuf.DoneStruct;
var i : integer;
begin
If (RowSlot <> nil) then
begin
For i := 0 to pred (NumSlots) do
If (RowSlot^ [i].Data <> nil) then FreeMem (RowSlot^ [i].Data, RecordSize);
FreeMem (RowSlot, NumSlots * sizeof (TSlot));
RowSlot := nil;
NumSlots := 0;
end;
TDmxEditor.DoneStruct;
end;
procedure TDmxEditBuf.HandleEvent (var Event : TEvent);
begin
With Event do
If (What = evBroadcast) and (NumSlots > 0) and
(((Command = cmDMX_DrawData) and (WorkingData = InfoPtr))
or
((Command = cmDMX_Draw)
and (InfoPtr <> @Self)
and (PDmxScroller (InfoPtr)^.WorkingData = WorkingData)))
then
begin
ResetSlots;
end;
TDmxEditor.HandleEvent (Event);
end;
procedure TDmxEditBuf.SetState (AState : word; Enable : boolean);
begin
If Enable and (AState and sfFocused <> 0) and (not RecordSelected) and
Expandable and (CurrentField <> nil) then
ResetSize;
TDmxEditor.SetState (AState, Enable);
end;
function